package com.cqjtu.eecs.controller;

import com.cqjtu.eecs.service.IFileTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.*;
import java.net.URLEncoder;

@Controller
@Api(tags = "文件模板下载链接")
@RequestMapping("/downloadTempLateFile")
public class FileTemplateController {

    @Autowired
    private IFileTemplateService fileTemplateService;

    @ApiOperation("课程模板文件的下载链接")
    @GetMapping("/Course")
    public @ResponseBody ResponseEntity<byte[]> Course() throws IOException {
        return fileTemplateService.excelTemplateExport("课程导入模板.xlsx");
    }

    @ApiOperation("培养方案模板文件的下载链接")
    @GetMapping("/TrainingScheme")
    public @ResponseBody ResponseEntity<byte[]> TrainingScheme() throws IOException {
        //String path=System.getProperty("user.dir") + "/src/main/resources/static/FileTemplate/" +"培养方案导入模板.xlsx";
        return fileTemplateService.excelTemplateExport("培养方案导入模板.xlsx");
    }

    @ApiOperation("学生录入模板文件的下载链接")
    @GetMapping("/Student")
    public @ResponseBody ResponseEntity<byte[]> Student() throws IOException {
        //String path=System.getProperty("user.dir") + "/src/main/resources/static/FileTemplate/" +"学生信息导入模板.xlsx";
        return fileTemplateService.excelTemplateExport("学生信息导入模板.xlsx");
    }

    @ApiOperation("课程大纲导入模板下载")
    @GetMapping("/course-outline")
    @ResponseBody
    public ResponseEntity<byte[]> getCourseOutline() throws IOException {
        return fileTemplateService.excelTemplateExport("课程大纲导入模板.xlsx");
    }

    @ApiOperation(value = "教师信息导入模板")
    @GetMapping("/teacher")
    @ResponseBody
    public ResponseEntity<byte[]> teacherInfoExcelTemplate() throws IOException {
        return fileTemplateService.excelTemplateExport("教师信息导入模板.xlsx");
    }

}
